﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IQKS.AWP.BusinessAccessLayer;
using IQKS.AWP.BusinessObject;
using System.IO;
using System.Configuration;

public partial class Admin_CandidateBriefDetailsRL : System.Web.UI.Page
{
    #region events
    public string PathBriefDoc = ConfigurationSettings.AppSettings["BriefDoc"];
    Int32 FileLimitSize = Convert.ToInt32(ConfigurationManager.AppSettings["FileLimitSize"].ToString());

    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            lblFileProposal.InnerText = "* Acceptable file formats " + Convert.ToString(ConfigurationManager.AppSettings["ProposalFileType"]).Replace("|", ",") + Convert.ToString(ConfigurationManager.AppSettings["FileSize"]);
            lblMRResearch.InnerText = "* Acceptable file formats " + Convert.ToString(ConfigurationManager.AppSettings["ProposalFileType"]).Replace("|", ",") + Convert.ToString(ConfigurationManager.AppSettings["FileSize"]);
            lblPastResearch.InnerText = "* Acceptable file formats " + Convert.ToString(ConfigurationManager.AppSettings["ProposalFileType"]).Replace("|", ",") + Convert.ToString(ConfigurationManager.AppSettings["FileSize"]);
            lblContentAnalysis.InnerText = "* Acceptable file formats " + Convert.ToString(ConfigurationManager.AppSettings["ProposalFileType"]).Replace("|", ",") + Convert.ToString(ConfigurationManager.AppSettings["FileSize"]);
            
           // mvwCandidateBriefDetails.
            mvwCandidateBriefDetails.ActiveViewIndex = 0;
            hdnMenuMoreDetail.Value = "0";
            hdnCandidateStageComplted.Value = "0";          
            btnPervious.Visible = false;
            mainMenu_MenuItemClick(sender, null);
            hdnBriefID.Value = Convert.ToString(Request.QueryString["BriefID"]);
            LoadBindData();
        }
    }


    private void LoadBindData()
    {
        DataSet objDs = new DataSet();
        objDs = GetCandidateBriefDetails();



        ActivityMasterBAL objActMstBAL = new ActivityMasterBAL();
        DataSet objjActMstDs = new DataSet();

        if (objDs.Tables.Count > 0)
        {
            //brief detail table
            if (objDs.Tables[0].Rows.Count > 0)
            {
                txtHideanBTitle.Text = Convert.ToString(objDs.Tables[0].Rows[0]["BriefTitle"]);
                tdBriefName.InnerHtml = Convert.ToString(objDs.Tables[0].Rows[0]["BriefTitle"]);
                tdBriefDesc.InnerHtml = Convert.ToString(objDs.Tables[0].Rows[0]["BriefDesc"]);
                tdBriefStartDt.InnerHtml = Convert.ToString(objDs.Tables[0].Rows[0]["BriefStartDate"]);
                tdBriefEndDt.InnerHtml = Convert.ToString(objDs.Tables[0].Rows[0]["BriefEndDate"]);
                hdnCandidateStatus.Value = Convert.ToString(objDs.Tables[0].Rows[0]["CandidateStatusID"]);
                hdnCandidateBriefId.Value = Convert.ToString(objDs.Tables[0].Rows[0]["CandidateBriefID"]);
                hdnCandidateID.Value = Convert.ToString(objDs.Tables[0].Rows[0]["CandidateID"]);
                hdnCandidateStageComplted.Value = Convert.ToString(objDs.Tables[0].Rows[0]["CandidateStageComplted"]);
                if (hdnCandidateStageComplted.Value.Trim() == "")
                { hdnCandidateStageComplted.Value = "0"; }
            }
            else
            {
                hdnCandidateStatus.Value = "0";
                hdnStageMode.Value = "0";
                btnNext.Visible = false;
            }

            //brief docuemnt details 
            if (objDs.Tables[1].Rows.Count > 0)
            {
                grdBriefDocument.DataSource = objDs.Tables[1];
                grdBriefDocument.DataBind();
            }

            //candidate query against breif 
            if (objDs.Tables[2].Rows.Count > 0)
            {
                DataView objDv = new DataView();
                objDv = objDs.Tables[2].DefaultView;
                objDv.RowFilter = "QueryTypeID  = 1";
                if (objDv.Count > 0)
                {
                    trQuestion.Visible = true;
                    trQuestionSpace1.Visible = true;
                    trAssessorComments.Visible = true;
                    rbtQuestion.Items[0].Selected = true;
                    trQuestionSpace2.Visible = true;
                    txtQuestionAssessor.Text = Convert.ToString(objDv[0]["Query"]);
                    txtAssessorComments.Text = Convert.ToString(objDv[0]["Answer"]);
                }
                else
                {
                    trQuestion.Visible = false;
                    trQuestionSpace1.Visible = false;
                    trAssessorComments.Visible = false;
                    rbtQuestion.Items[1].Selected = true;
                    trQuestionSpace2.Visible = false;
                 
                }


                objDv.RowFilter = "QueryTypeID  = 2";
                if (objDv.Count > 0)
                {
                    hdnMenuMoreDetail.Value = Convert.ToString(objDv[0]["CandidateQueryID"]);
                    txtQuestionMore.Text = Convert.ToString(objDv[0]["Query"]);
                    txtCommentsMore.Text = Convert.ToString(objDv[0]["Answer"]);
                    hdnCandidateQueryID.Value = Convert.ToString(objDv[0]["QueryTypeID"]);
                    if (txtCommentsMore.Text.Trim().Length == 0)
                    {
                        txtCommentsMore.Enabled = true;
                        btnMoreCommentAdd.Enabled = true;
                        btnMoreCommentCancel.Enabled = true;
                    }
                    else
                    {
                        txtCommentsMore.Enabled = false;
                        btnMoreCommentAdd.Enabled = false;
                        btnMoreCommentCancel.Enabled = false;
                    }
                }

            }
            else
            {
                trQuestion.Visible = false;
                trQuestionSpace1.Visible = false;
                trQuestionSpace2.Visible = false;
                trAssessorComments.Visible = false;
                rbtQuestion.Items[1].Selected = true;
            }

            if (objDs.Tables[3].Rows.Count > 0)
            {
                DataView objDv = new DataView();
                objDv = objDs.Tables[3].DefaultView;
                objDv.RowFilter = "DocumentTypeID  = 1";
                if (objDv.Count > 0)
                {
                    gvProposalDocument.DataSource = objDv;
                    gvProposalDocument.DataBind();
                }
              

                objDv.RowFilter = "DocumentTypeID  = 3";
                if (objDv.Count > 0)
                {
                    gvContentAnalysis.DataSource = objDv;
                    gvContentAnalysis.DataBind();
                }

                objDv.RowFilter = "DocumentTypeID  = 4";
                if (objDv.Count > 0)
                {
                    gvPastResearch.DataSource = objDv;
                    gvPastResearch.DataBind();
                }

                objDv.RowFilter = "DocumentTypeID  = 5";
                if (objDv.Count > 0)
                {
                    gvMRResearch.DataSource = objDv;
                    gvMRResearch.DataBind();
                }
             
            }

            //remove more details
            if (hdnMenuMoreDetail.Value == "0")
            {
                mainMenu.Items.Remove(mainMenu.Items[5]);
            }
            else
            {
                 mainMenu.Items[5].Enabled = false;
            }

           
            StageWiseDisable();
          
        }
        else
        {
            hdnCandidateStatus.Value = "0";
            hdnStageMode.Value = "0";
            btnNext.Visible = false;
        }
    }


   

    private void StageWiseDisable()
    {
            if (hdnCandidateStatus.Value == "22")
            {
                hdnStageMode.Value = "1";
                txtQuestionAssessor.Enabled = true;
                regQuestionAssessor.Enabled = true;
                txtAssessorComments.Enabled = false;
                rbtQuestion.Enabled = true;
                chkConfirm.Enabled = true;
                grdBriefDocument.Enabled = true;

            }
            else
            {
                txtQuestionAssessor.Enabled = false;
                regQuestionAssessor.Enabled = false;
                txtAssessorComments.Enabled = false;
                hdnStageMode.Value = "0";
                rbtQuestion.Enabled = false;
                chkConfirm.Enabled = false;
                grdBriefDocument.Enabled = false;
                chkConfirm.Checked = true;
            }


            if (hdnCandidateStatus.Value == "5")
            {
                hdnProposalStageMode.Value = "1";
                filProposal.Enabled = true;
                txtComments.Enabled = true;
                btnProposal.Enabled = true;
                chkProposal.Enabled = true;
                chkProposal.Checked = false;
                btnCancelProposal.Enabled = true;
                gvProposalDocument.Columns[3].Visible = true;

            }
            else
            {
                hdnProposalStageMode.Value = "0";
                filProposal.Enabled = false;
                txtComments.Enabled = false;
                btnProposal.Enabled = false;
                chkProposal.Enabled = false;
                chkProposal.Checked = true;
                btnCancelProposal.Enabled = false;
                gvProposalDocument.Columns[3].Visible = false;

            }


            if (hdnCandidateStatus.Value == "6")
            {
                hdnCAStageMode.Value = "1";
                fileContentAnalysis.Enabled = true;
                txtContentAnalysis.Enabled = true;
                btnContentAnalysis.Enabled = true;
                chkContentAnalysis.Enabled = true;
                chkContentAnalysis.Checked = false;
                gvContentAnalysis.Enabled = true;
                btnCancelContentAnalysis.Enabled = true;
                gvContentAnalysis.Columns[3].Visible = true;

            }
            else
            {
                hdnCAStageMode.Value = "0";
                fileContentAnalysis.Enabled = false;
                txtContentAnalysis.Enabled = false;
                btnContentAnalysis.Enabled = false;
                chkContentAnalysis.Enabled = false;
                gvContentAnalysis.Enabled = false;
                chkContentAnalysis.Checked = true;
                btnCancelContentAnalysis.Enabled = false;
                gvContentAnalysis.Columns[3].Visible = false;

            }


            if (hdnCandidateStatus.Value == "8")
            {
                hdnMRStageMode.Value = "1";
                filePastResearch.Enabled = true;
                fileMRResearch.Enabled = true;
                txtPastResearch.Enabled = true;
                txtMRResearch.Enabled = true;
                btnAddMRResearch.Enabled = true;
                btnAddPastResearch.Enabled = true;
                chkMRResearch.Enabled = true;
                chkMRResearch.Checked = false;
                gvMRResearch.Enabled = true;
                gvPastResearch.Enabled = true;
                btnCancelMRResearch.Enabled = true;
                btnCancelPastResearch.Enabled = true;
                gvMRResearch.Columns[3].Visible = true;
                gvPastResearch.Columns[3].Visible = true;

            }
            else
            {
                hdnMRStageMode.Value = "0";
                filePastResearch.Enabled = false;
                fileMRResearch.Enabled = false;
                txtPastResearch.Enabled = false;
                txtMRResearch.Enabled = false;
                btnAddMRResearch.Enabled = false;
                btnAddPastResearch.Enabled = false;
                chkMRResearch.Enabled = false;
                chkMRResearch.Checked = true;
                gvMRResearch.Enabled = false;
                gvPastResearch.Enabled = false;
                btnCancelMRResearch.Enabled = false;
                btnCancelPastResearch.Enabled = false;
                gvMRResearch.Columns[3].Visible = false;
                gvPastResearch.Columns[3].Visible = false;
            }

            
            //last stage
            if (hdnCandidateStatus.Value == "24"  )
            {
                // mainMenu.Items.Remove(mainMenu.Items[6]);
                //brijal added as on 28022017 for after Finish click document upload enable
                fileContentAnalysis.Enabled = true;
                btnContentAnalysis.Enabled = true;
                filePastResearch.Enabled = true;
                btnAddPastResearch.Enabled = true;
                fileMRResearch.Enabled = true;
                btnAddMRResearch.Enabled = true;
            }
            else
            {
                
            }
        
    }
    
    protected void mainMenu_MenuItemClick(object sender, MenuEventArgs e)
    {
        int intActiveIndex;
        if (e != null)
        {
            mvwCandidateBriefDetails.ActiveViewIndex = Int32.Parse(e.Item.Value);
        }

        intActiveIndex = mvwCandidateBriefDetails.ActiveViewIndex;
        
        switch (intActiveIndex)
        {
            case 0:
                
                mainMenu.Items[0].Enabled = true;
                mainMenu.Items[1].Enabled = false;
                mainMenu.Items[2].Enabled = false;
                mainMenu.Items[3].Enabled = false;
                mainMenu.Items[4].Enabled = false;

                if (Convert.ToInt32(hdnMenuMoreDetail.Value) > 0)
                { mainMenu.Items[5].Enabled = false; }
                btnPervious.Visible = false;
                btnNext.Visible = true;
                btnNext.Text = "Next";
               
                break;
            case 1:
                mainMenu.Items[0].Enabled = true;
                mainMenu.Items[1].Enabled = true;
                mainMenu.Items[2].Enabled = false;
                mainMenu.Items[3].Enabled = false;
                mainMenu.Items[4].Enabled = false;
               
                if (Convert.ToInt32(hdnMenuMoreDetail.Value) > 0)
                {
                    mainMenu.Items[5].Enabled = false;
                }

                btnPervious.Visible = true;
                btnNext.Visible = true;
                btnNext.Text = "Next";
                break;
            case 2:
                mainMenu.Items[0].Enabled = true;
                mainMenu.Items[1].Enabled = true;
                mainMenu.Items[2].Enabled = true;
                mainMenu.Items[3].Enabled = false;
                mainMenu.Items[4].Enabled = false;
                if (Convert.ToInt32(hdnMenuMoreDetail.Value) > 0)
                {
                    mainMenu.Items[5].Enabled = false;
                }
                btnPervious.Visible = true;
                btnNext.Visible = true;
                btnNext.Text = "Next";
                break;
            case 3:
                mainMenu.Items[0].Enabled = true;
                mainMenu.Items[1].Enabled = true;
                mainMenu.Items[2].Enabled = true;
                mainMenu.Items[3].Enabled = true;
                mainMenu.Items[4].Enabled = false;
                mainMenu.Items[5].Enabled = false;
                if (Convert.ToInt32(hdnMenuMoreDetail.Value) > 0)
                {
                    mainMenu.Items[5].Enabled = false;
                }
                btnPervious.Visible = true;
                btnNext.Visible = true;
                btnNext.Text = "Next";
                break;
            case 4:
                mainMenu.Items[0].Enabled = true;
                mainMenu.Items[1].Enabled = true;
                mainMenu.Items[2].Enabled = true;
                mainMenu.Items[3].Enabled = true;
                mainMenu.Items[4].Enabled = true;
                if (Convert.ToInt32(hdnMenuMoreDetail.Value) > 0)
                {
                    mainMenu.Items[5].Enabled = false;
                }
                btnPervious.Visible = true;
                btnNext.Visible = true;
                btnNext.Text = "Next";
                break;
            case 5:
                mainMenu.Items[0].Enabled = true;
                mainMenu.Items[1].Enabled = true;
                mainMenu.Items[2].Enabled = true;
                mainMenu.Items[3].Enabled = true;
                mainMenu.Items[4].Enabled = true;

                if (Convert.ToInt32(hdnMenuMoreDetail.Value) > 0)
                {
                    mainMenu.Items[5].Enabled = false;

                    btnNext.Text = "Next";
                    btnNext.Visible = true;
                }
                else
                {

                    if (hdnCandidateStageComplted.Value == "24")
                    {
                        btnNext.Text = "Finish";
                        btnNext.Visible = false;
                    }
                    else
                    {
                        btnNext.Text = "Finish";
                        btnNext.Visible = true;
                    }
                }
                btnPervious.Visible = true;
                
                break;
            case 6:
                mainMenu.Items[0].Enabled = true;
                mainMenu.Items[1].Enabled = true;
                mainMenu.Items[2].Enabled = true;
                mainMenu.Items[3].Enabled = true;
                mainMenu.Items[4].Enabled = true;
                mainMenu.Items[5].Enabled = true;

                btnPervious.Visible = true;
                btnNext.Visible = false;
                break;
              
        }
    }


    protected void btnNext_Click(object sender, EventArgs e)
    {
        if(Page.IsValid == true)
        { 
              NextBothClick();
        }
    }


    protected void btnPervious_Click(object sender, EventArgs e)
    {
        PreviousBothClick();

    }


    protected void btnProposal_Click(object sender, EventArgs e)
    {
        if (Page.IsValid == true)
        {
             try
            {

                SaveDocument("PROPOSAL");
                txtComments.Text = "";
            }
             catch (Exception ex)
             {
                 lblMessage.Text = "Error while saving Record : " + ex.Message;

             }
             finally
             {


                 ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Proposal Document Uploaded Successfully.');", true);
             }
        }

    }

    #endregion


    private void PreviousBothClick()
    {
        switch (mvwCandidateBriefDetails.ActiveViewIndex)
        {
            case 1:
                StageWiseDisable();
                mvwCandidateBriefDetails.ActiveViewIndex = 0;
                btnPervious.Visible = false;
                btnNext.Visible = true;
                mainMenu.Items[0].Enabled = true;
                mainMenu.Items[1].Enabled = false;
                mainMenu.Items[2].Enabled = false;
                mainMenu.Items[3].Enabled = false;
                mainMenu.Items[4].Enabled = false;
                              
                if (Convert.ToInt32(hdnMenuMoreDetail.Value) > 0)
                {
                    mainMenu.Items[5].Enabled = false;
                   
                }
                btnNext.Text = "Next";
                break;
            case 2:
                StageWiseDisable();
                mvwCandidateBriefDetails.ActiveViewIndex = 1;
                btnPervious.Visible = true;
                btnNext.Visible = true;
                mainMenu.Items[0].Enabled = true;
                mainMenu.Items[1].Enabled = true;
                mainMenu.Items[2].Enabled = false;
                mainMenu.Items[3].Enabled = false;
                mainMenu.Items[4].Enabled = false;
                if (Convert.ToInt32(hdnMenuMoreDetail.Value) > 0)
                {
                    mainMenu.Items[5].Enabled = false;

                }
                btnNext.Text = "Next";
                // mainMenu.Items[7].Enabled = false;
                break;
           
            case 3:
                mvwCandidateBriefDetails.ActiveViewIndex = 2;
                btnPervious.Visible = true;
                btnNext.Visible = true;
                mainMenu.Items[0].Enabled = true;
                mainMenu.Items[1].Enabled = true;
                mainMenu.Items[2].Enabled = true;
                mainMenu.Items[3].Enabled = false;
                mainMenu.Items[4].Enabled = false;
                if (Convert.ToInt32(hdnMenuMoreDetail.Value) > 0)
                {
                    mainMenu.Items[5].Enabled = false;
                }
                btnNext.Text = "Next";
                break;
            case 4:
                mvwCandidateBriefDetails.ActiveViewIndex = 3;
                btnPervious.Visible = true;
                btnNext.Visible = true;
                mainMenu.Items[0].Enabled = true;
                mainMenu.Items[1].Enabled = true;
                mainMenu.Items[2].Enabled = true;
                mainMenu.Items[3].Enabled = true;
                mainMenu.Items[4].Enabled = false;
                
                if (Convert.ToInt32(hdnMenuMoreDetail.Value) > 0)
                {
                    mainMenu.Items[5].Enabled = false;
                }
                btnNext.Text = "Next";
                //mainMenu.Items[7].Enabled = false;
                break;
            case 5:
                mvwCandidateBriefDetails.ActiveViewIndex = 4;
                btnPervious.Visible = true;
                btnNext.Visible = true;
                mainMenu.Items[0].Enabled = true;
                mainMenu.Items[1].Enabled = true;
                mainMenu.Items[2].Enabled = true;
                mainMenu.Items[3].Enabled = true;
                mainMenu.Items[4].Enabled = true;
                if (Convert.ToInt32(hdnMenuMoreDetail.Value) > 0)
                {
                    mainMenu.Items[5].Enabled = false;
                    btnNext.Text = "Next";
                }
                else
                {
                    btnNext.Text = "Finish";
                }

                break;
        }
    }

    private void NextBothClick()
    {
        switch (mvwCandidateBriefDetails.ActiveViewIndex)
        {
            case 0:
                if (Convert.ToInt16(hdnStageMode.Value) == 1 && Convert.ToInt16(hdnCandidateStatus.Value) == 22)
                {
                    string strReturnValue;
                    strReturnValue = SaveCandidateBriefDetail();
                    if (strReturnValue == "SUCCESS")
                    {
                        hdnCandidateStatus.Value = "5";
                    }
                }
                StageWiseDisable();
                mvwCandidateBriefDetails.ActiveViewIndex = 1;
                btnPervious.Visible = true;
                btnNext.Visible = true;
                
                mainMenu.Items[0].Enabled = true;
                mainMenu.Items[1].Enabled = true;
                mainMenu.Items[2].Enabled = false;
                mainMenu.Items[3].Enabled = false;
                mainMenu.Items[4].Enabled = false;
                

                if (Convert.ToInt32(hdnMenuMoreDetail.Value) > 0)
                { mainMenu.Items[5].Enabled = false; }

                break;
            case 1:
                if (Convert.ToInt16(hdnProposalStageMode.Value) == 1 && Convert.ToInt16(hdnCandidateStatus.Value) == 5)
                {
                    string strReturnValue;
                    strReturnValue = SaveCandidateBriefDetail();
                    if (strReturnValue == "SUCCESS")
                    {
                        hdnCandidateStatus.Value = "6";
                    }
                }
                StageWiseDisable();
                mvwCandidateBriefDetails.ActiveViewIndex = 2;
                btnPervious.Visible = true;
                btnNext.Visible = true;
                mainMenu.Items[0].Enabled = true;
                mainMenu.Items[1].Enabled = true;
                mainMenu.Items[2].Enabled = true;
                mainMenu.Items[3].Enabled = false;
                mainMenu.Items[4].Enabled = false;
               
                if (Convert.ToInt32(hdnMenuMoreDetail.Value) > 0)
                { mainMenu.Items[5].Enabled = false; }


                break;

            case 2:
               
                if (Convert.ToInt16(hdnCAStageMode.Value) == 1 && Convert.ToInt16(hdnCandidateStatus.Value) == 6)
                {
                    string strReturnValue;
                    strReturnValue = SaveCandidateBriefDetail();
                    if (strReturnValue == "SUCCESS")
                    {
                        hdnCandidateStatus.Value = "8";
                    }
                }
                StageWiseDisable();
                mvwCandidateBriefDetails.ActiveViewIndex = 3;
                btnPervious.Visible = true;
                btnNext.Visible = true;
                mainMenu.Items[0].Enabled = true;
                mainMenu.Items[1].Enabled = true;
                mainMenu.Items[2].Enabled = true;
                mainMenu.Items[3].Enabled = true;
                mainMenu.Items[4].Enabled = true;
               
                if (Convert.ToInt32(hdnMenuMoreDetail.Value) > 0)
                { mainMenu.Items[5].Enabled = false; }


                break;
            case 3:
                StageWiseDisable();
                mvwCandidateBriefDetails.ActiveViewIndex = 4;
                btnPervious.Visible = true;
                btnNext.Visible = true;
                mainMenu.Items[0].Enabled = true;
                mainMenu.Items[1].Enabled = true;
                mainMenu.Items[2].Enabled = true;
                mainMenu.Items[3].Enabled = true;
                mainMenu.Items[4].Enabled = true;
               
                if (Convert.ToInt32(hdnMenuMoreDetail.Value) > 0)
                {
                    mainMenu.Items[5].Enabled = true;
                    btnNext.Text = "Next";
                }
                else
                {
                    btnNext.Text = "Finish";
                    if (hdnCandidateStageComplted.Value == "24")
                    {
                        btnNext.Visible = false;
                    }
                    else
                    {
                        btnNext.Visible = true;
                    }
                }

                break;
            case 4:
                if (Convert.ToInt16(hdnMRStageMode.Value) == 1 && Convert.ToInt16(hdnCandidateStatus.Value) == 8)
                {
                    string strReturnValue;
                    strReturnValue = SaveCandidateBriefDetail();
                    if (strReturnValue == "SUCCESS")
                    {
                        hdnCandidateStatus.Value = "24";
                        Response.Redirect("CandidateBriefThank.aspx",true);
                    }
                }
                StageWiseDisable();
                //mvwCandidateBriefDetails.ActiveViewIndex = 6;
                btnPervious.Visible = true;
                btnNext.Visible = false;
                mainMenu.Items[0].Enabled = true;
                mainMenu.Items[1].Enabled = true;
                mainMenu.Items[2].Enabled = true;
                mainMenu.Items[3].Enabled = true;
                mainMenu.Items[4].Enabled = true;
               
                if (Convert.ToInt32(hdnMenuMoreDetail.Value) > 0)
                {
                    mvwCandidateBriefDetails.ActiveViewIndex = 5;
                    mainMenu.Items[5].Enabled = true;
                    btnNext.Text = "Next";
                }
                else
                {
                    btnNext.Text = "Finish";
                    if (hdnCandidateStageComplted.Value == "24")
                    {
                        btnNext.Visible = false;
                    }
                    else
                    {
                        btnNext.Visible = true;
                    }
                }

                break;
            case 5:
                mvwCandidateBriefDetails.ActiveViewIndex = 5;
                btnPervious.Visible = true;
                btnNext.Visible = false;
                mainMenu.Items[0].Enabled = true;
                mainMenu.Items[1].Enabled = true;
                mainMenu.Items[2].Enabled = true;
                mainMenu.Items[3].Enabled = true;
                mainMenu.Items[4].Enabled = true;
                mainMenu.Items[5].Enabled = true;
                break;
        }
    }

    //all candidate type
    private DataSet GetCandidateBriefDetails()
    {
        DataSet objDs=null;
        try
        {
            //todo  CommonUtility.GetLoggedOnUserId()
            objDs = new CandidateBriefDetailBAL().GetCandidateBriefByCandidateID(CommonUtility.GetLoggedOnUserId(), Convert.ToInt16(hdnBriefID.Value));

        }
        catch (Exception exception)
        {
            exception.AddErrorToLog();// throw new ApplicationException(exception.Message);
        }
        return objDs;

    }

    //all candidate type
    private string SaveCandidateBriefDetail()
    {
        CandidateBriefDetailBAL objCBDBAL = new CandidateBriefDetailBAL();
        string strReturnValue;

        strReturnValue = (string)objCBDBAL.SetCandidateBriefByStatusID(CommonUtility.GetLoggedOnUserId(), Convert.ToInt32(hdnCandidateBriefId.Value), Convert.ToInt32(hdnCandidateID.Value), Convert.ToInt16(hdnBriefID.Value), Convert.ToInt16(hdnCandidateStatus.Value), txtQuestionAssessor.Text.Trim(), Convert.ToBoolean(rbtQuestion.Items[0].Selected));
        return strReturnValue;
    }

    //all candidate type
    private void SaveDocument(string strFileType)
    {
        string strPath = string.Empty;
        string strFileExt = string.Empty;
        string strFileName = string.Empty;

        if (strFileType == "PROPOSAL")
        {
            strFileExt = Path.GetExtension(filProposal.PostedFile.FileName);
            strFileName = Path.GetFileNameWithoutExtension(filProposal.FileName);
            strPath = MapPath(Convert.ToString(ConfigurationManager.AppSettings["ProposalPath"]));

            CandidateBriefDetailBAL objCBDBAL = new CandidateBriefDetailBAL();
            strFileName = (string)objCBDBAL.SetCandidateBriefDocument(CommonUtility.GetLoggedOnUserId(), Convert.ToInt32(hdnCandidateBriefId.Value), Convert.ToInt32(hdnCandidateID.Value), Convert.ToInt16(hdnBriefID.Value), Convert.ToInt16(hdnCandidateStatus.Value), 1, strFileName, strFileExt, txtComments.Text.Trim());
            if (strFileName != "ERROR")
            {
                //filProposal.SaveAs(strPath + strFileName);
                CommonUtility.SaveFile(filProposal, strPath, strFileName);
                gvProposalDocument.DataSource = objCBDBAL.GetCandidateBriefDocumentByDocumentType(1, Convert.ToInt32(hdnCandidateID.Value), Convert.ToInt16(hdnBriefID.Value));
                gvProposalDocument.DataBind();
            }
           
        }
       
        else if (strFileType == "CONTENTANALYSIS")
        {
            strFileExt = Path.GetExtension(fileContentAnalysis.PostedFile.FileName);
            strFileName = Path.GetFileNameWithoutExtension(fileContentAnalysis.FileName);
            strPath = MapPath(Convert.ToString(ConfigurationManager.AppSettings["ProposalPath"]));

            CandidateBriefDetailBAL objCBDBAL = new CandidateBriefDetailBAL();
            strFileName = (string)objCBDBAL.SetCandidateBriefDocument(CommonUtility.GetLoggedOnUserId(), Convert.ToInt32(hdnCandidateBriefId.Value), Convert.ToInt32(hdnCandidateID.Value), Convert.ToInt16(hdnBriefID.Value), Convert.ToInt16(hdnCandidateStatus.Value),3, strFileName, strFileExt, txtContentAnalysis.Text.Trim());
            if (strFileName != "ERROR")
            {
                //fileContentAnalysis.SaveAs(strPath + strFileName);
                CommonUtility.SaveFile(fileContentAnalysis, strPath, strFileName);
                gvContentAnalysis.DataSource = objCBDBAL.GetCandidateBriefDocumentByDocumentType(3, Convert.ToInt32(hdnCandidateID.Value), Convert.ToInt16(hdnBriefID.Value));
                gvContentAnalysis.DataBind();
            }
        }
        else if (strFileType == "PASTRESEARCH")
        {
            strFileExt = Path.GetExtension(filePastResearch.PostedFile.FileName);
            strFileName = Path.GetFileNameWithoutExtension(filePastResearch.FileName);
            strPath = MapPath(Convert.ToString(ConfigurationManager.AppSettings["ProposalPath"]));

            CandidateBriefDetailBAL objCBDBAL = new CandidateBriefDetailBAL();
            strFileName = (string)objCBDBAL.SetCandidateBriefDocument(CommonUtility.GetLoggedOnUserId(), Convert.ToInt32(hdnCandidateBriefId.Value), Convert.ToInt32(hdnCandidateID.Value), Convert.ToInt16(hdnBriefID.Value), Convert.ToInt16(hdnCandidateStatus.Value), 4, strFileName, strFileExt, txtPastResearch.Text.Trim());
            if (strFileName != "ERROR")
            {
                //filePastResearch.SaveAs(strPath + strFileName);
                CommonUtility.SaveFile(filePastResearch, strPath, strFileName);
                gvPastResearch.DataSource = objCBDBAL.GetCandidateBriefDocumentByDocumentType(4, Convert.ToInt32(hdnCandidateID.Value), Convert.ToInt16(hdnBriefID.Value));
                gvPastResearch.DataBind();
            }
        }
        else if (strFileType == "MRRESEARCH")
        {
            strFileExt = Path.GetExtension(fileMRResearch.PostedFile.FileName);
            strFileName = Path.GetFileNameWithoutExtension(fileMRResearch.FileName);
            strPath = MapPath(Convert.ToString(ConfigurationManager.AppSettings["ProposalPath"]));

            CandidateBriefDetailBAL objCBDBAL = new CandidateBriefDetailBAL();
            strFileName = (string)objCBDBAL.SetCandidateBriefDocument(CommonUtility.GetLoggedOnUserId(), Convert.ToInt32(hdnCandidateBriefId.Value), Convert.ToInt32(hdnCandidateID.Value), Convert.ToInt16(hdnBriefID.Value), Convert.ToInt16(hdnCandidateStatus.Value), 5, strFileName, strFileExt, txtMRResearch.Text.Trim());
            if (strFileName != "ERROR")
            {
                //fileMRResearch.SaveAs(strPath + strFileName);
                CommonUtility.SaveFile(fileMRResearch, strPath, strFileName);
                gvMRResearch.DataSource = objCBDBAL.GetCandidateBriefDocumentByDocumentType(5, Convert.ToInt32(hdnCandidateID.Value), Convert.ToInt16(hdnBriefID.Value));
                gvMRResearch.DataBind();
            }
        }
    }

    //all candidate type
    protected void rbtQuestion_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (rbtQuestion.SelectedValue == "YES")
        {
            trAssessorComments.Visible = true;
            trQuestion.Visible = true;
            trQuestionSpace1.Visible = true;
            trQuestionSpace2.Visible = true;
        }
        else
        {
            trAssessorComments.Visible = false;
            trQuestion.Visible = false;
            trQuestionSpace1.Visible = false;
            trQuestionSpace2.Visible = false;
        }
    }
  
    protected void cstProposal_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (filProposal.PostedFile == null)
        {
            args.IsValid = false;
            cstProposal.ErrorMessage = "Select file to attach.";
            return;
        }
        else
        {
            if (filProposal.PostedFile.FileName == "")
            {
                args.IsValid = false;
                cstProposal.ErrorMessage = "Select file to attach.";
                return;
            }
            else if (filProposal.PostedFile.FileName != "")
            {
                /*check file is valid*/
                if (filProposal.PostedFile.ContentLength == 0)
                {
                    args.IsValid = false;
                    cstProposal.ErrorMessage = "Select Valid file.";
                    return;
                }

                int fileSize = filProposal.PostedFile.ContentLength;

                if (fileSize > (FileLimitSize))
                {
                    args.IsValid = false;
                    cstProposal.ErrorMessage = "Document" + Convert.ToString(ConfigurationManager.AppSettings["FileSize"]);// "Document size should not be more than 5 MB.";
                    return;
                }
                /*Check file name has extension*/
                if (System.IO.Path.HasExtension(filProposal.PostedFile.FileName) == true)
                {

                    /*check void extension are there or not*/
                    if (CommonUtility.CheckExtension(Path.GetExtension(filProposal.PostedFile.FileName), Convert.ToString(ConfigurationManager.AppSettings["ProposalFileType"])) == false)
                    {
                        args.IsValid = false;
                        cstProposal.ErrorMessage = "Upload File failed. Select file format as per below.";
                        return;
                    }

                }
            }
        }
    }
    protected void btnGDDocument_Click(object sender, EventArgs e)
    {
        if (Page.IsValid == true)
        {
            SaveDocument("GDDOCUMENT");
        }
    }


    protected void cstContentAnalysis_ServerValidate(object source, ServerValidateEventArgs args)
    { 
    
        if (fileContentAnalysis.PostedFile == null)
        {
            args.IsValid = false;
            cstContentAnalysis.ErrorMessage = "Select file to attach.";
            return;
        }
        else
        {
            if (fileContentAnalysis.PostedFile.FileName == "")
            {
                args.IsValid = false;
                cstContentAnalysis.ErrorMessage = "Select file to attach.";
                return;
            }
            else if (fileContentAnalysis.PostedFile.FileName != "")
            {
                /*check file is valid*/
                if (fileContentAnalysis.PostedFile.ContentLength == 0)
                {
                    args.IsValid = false;
                    cstContentAnalysis.ErrorMessage = "Select Valid file.";
                    return;
                }

                int fileSize = fileContentAnalysis.PostedFile.ContentLength;

                if (fileSize > (FileLimitSize))
                {
                    args.IsValid = false;
                    cstContentAnalysis.ErrorMessage = "Document" + Convert.ToString(ConfigurationManager.AppSettings["FileSize"]);// "Document size should not be more than 5 MB.";
                    return;
                }
                /*Check file name has extension*/
                if (System.IO.Path.HasExtension(fileContentAnalysis.PostedFile.FileName) == true)
                {

                    /*check void extension are there or not*/
                    if (CommonUtility.CheckExtension(Path.GetExtension(fileContentAnalysis.PostedFile.FileName), Convert.ToString(ConfigurationManager.AppSettings["ProposalFileType"])) == false)
                    {
                        args.IsValid = false;
                        cstContentAnalysis.ErrorMessage = "Upload File failed. Select file format as per below.";
                        return;
                    }

                }
            }
        }
    }


    protected void btnContentAnalysis_Click(object sender, EventArgs e)
    {
        if (Page.IsValid == true)
        {
             try
            {

                SaveDocument("CONTENTANALYSIS");
                txtContentAnalysis.Text = "";
            }
             catch (Exception ex)
             {
                 lblMessage.Text = "Error while saving Record : " + ex.Message;

             }
             finally
             {


                 ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Full Report Document Uploaded Successfully.');", true);
             }

        }
    }
    protected void cstPastResearch_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (filePastResearch.PostedFile == null)
        {
            args.IsValid = false;
            cstPastResearch.ErrorMessage = "Select file to attach.";
            return;
        }
        else
        {
            if (filePastResearch.PostedFile.FileName == "")
            {
                args.IsValid = false;
                cstPastResearch.ErrorMessage = "Select file to attach.";
                return;
            }
            else if (filePastResearch.PostedFile.FileName != "")
            {
                /*check file is valid*/
                if (filePastResearch.PostedFile.ContentLength == 0)
                {
                    args.IsValid = false;
                    cstPastResearch.ErrorMessage = "Select Valid file.";
                    return;
                }

                int fileSize = filePastResearch.PostedFile.ContentLength;

                if (fileSize > (FileLimitSize))
                {
                    args.IsValid = false;
                    cstPastResearch.ErrorMessage = "Document" + Convert.ToString(ConfigurationManager.AppSettings["FileSize"]);// "Document size should not be more than 5 MB.";
                    return;
                }
                /*Check file name has extension*/
                if (System.IO.Path.HasExtension(filePastResearch.PostedFile.FileName) == true)
                {

                    /*check void extension are there or not*/
                    if (CommonUtility.CheckExtension(Path.GetExtension(filePastResearch.PostedFile.FileName), Convert.ToString(ConfigurationManager.AppSettings["ProposalFileType"])) == false)
                    {
                        args.IsValid = false;
                        cstPastResearch.ErrorMessage = "Upload File failed. Select file format as per below.";
                        return;
                    }

                }
            }
        }
    }
    protected void cstMRResearch_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (fileMRResearch.PostedFile == null)
        {
            args.IsValid = false;
            cstMRResearch.ErrorMessage = "Select file to attach.";
            
            return;
        }
        else
        {
            if (fileMRResearch.PostedFile.FileName == "")
            {
                args.IsValid = false;
                cstMRResearch.ErrorMessage = "Select file to attach.";
                return;
            }
            else if (fileMRResearch.PostedFile.FileName != "")
            {
                /*check file is valid*/
                if (fileMRResearch.PostedFile.ContentLength == 0)
                {
                    args.IsValid = false;
                    cstMRResearch.ErrorMessage = "Select Valid file.";
                    return;
                }

                int fileSize = fileMRResearch.PostedFile.ContentLength;

                if (fileSize > (FileLimitSize))
                {
                    args.IsValid = false;
                    cstMRResearch.ErrorMessage = "Document" + Convert.ToString(ConfigurationManager.AppSettings["FileSize"]); //"Document size should not be more than 5 MB.";
                    return;
                }

                /*Check file name has extension*/
                if (System.IO.Path.HasExtension(fileMRResearch.PostedFile.FileName) == true)
                {

                    /*check void extension are there or not*/
                    if (CommonUtility.CheckExtension(Path.GetExtension(fileMRResearch.PostedFile.FileName), Convert.ToString(ConfigurationManager.AppSettings["ProposalFileType"])) == false)
                    {
                        args.IsValid = false;
                        cstMRResearch.ErrorMessage = "Upload File failed. Select file format as per below.";
                        return;
                    }

                }
            }
        }
    }

    protected void btnAddPastResearch_Click(object sender, EventArgs e)
    {
        if (Page.IsValid == true)
        {
             try
            {
                SaveDocument("PASTRESEARCH");
                txtPastResearch.Text = "";
            }
             catch (Exception ex)
             {
                 lblMessage.Text = "Error while saving Record : " + ex.Message;

             }
             finally
             {


                 ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Past Research Document Uploaded Successfully.');", true);
             }
        }
    }
    protected void btnAddMRResearch_Click(object sender, EventArgs e)
    {
        if (Page.IsValid == true)
        {
             try
            {
                SaveDocument("MRRESEARCH");
                txtMRResearch.Text = "";
            }
             catch (Exception ex)
             {
                 lblMessage.Text = "Error while saving Record : " + ex.Message;

             }
             finally
             {


                 ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Market Research Report Document Uploaded Successfully.');", true);
             }
        }
    }
    protected void btnMoreCommentAdd_Click(object sender, EventArgs e)
    {
        if (Page.IsValid == true)
        {
             try
            {
                SaveMoreDetails();
                txtCommentsMore.Enabled = false;
                btnMoreCommentCancel.Enabled = false;
                btnMoreCommentAdd.Enabled = false;
            }
             catch (Exception ex)
             {
                 lblMessage.Text = "Error while saving Record : " + ex.Message;

             }
             finally
             {


                 ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Questions from Assessor Added Successfully.');", true);
             }

        }
    }

    private string SaveMoreDetails()
    {
        CandidateBriefDetailBAL objCBDBAL = new CandidateBriefDetailBAL();
        string strReturnValue;

        strReturnValue = (string)objCBDBAL.SetCandidateMoreComments(Convert.ToInt32(hdnMenuMoreDetail.Value), CommonUtility.GetLoggedOnUserId(), Convert.ToInt32(hdnCandidateBriefId.Value), 2, txtCommentsMore.Text.Trim());
        return strReturnValue;
    }
   

    protected void btnCancelGDDetails_Click(object sender, EventArgs e)
    {

    }
    

   
    protected void gvGroupDiscussion_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton lnkButton = (LinkButton)e.Row.FindControl("lnkDelete");

            lnkButton.Attributes.Add("onclick", "javascript:return " + "confirm('Are you sure you want to delete?')");
            
        }
    }

   
    protected void cstGvProposalDocument_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (gvProposalDocument.Rows.Count <= 0)
        {
            args.IsValid = false;
            cstGvProposalDocument.ErrorMessage = "Upload proposal document to proceed next stage.";
            return;
        }
    }

    protected void csvContentAnalysis_ServerValidate(object source, ServerValidateEventArgs args)
    {

        if (gvContentAnalysis.Rows.Count <= 0)
        {
            args.IsValid = false;
            csvContentAnalysis.ErrorMessage = "Upload Content Analysis document to proceed next stage.";
            return;
        }
    }

    protected void cstGrdMRResearch_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (gvMRResearch.Rows.Count <= 0)
        {
            args.IsValid = false;
            cstGrdMRResearch.ErrorMessage = "Upload MR Research document to complete accreditation process.";
            return;
        }
    }

    public string GetBriefDownload(object objDocumentFile)
    {
        string strPath = string.Empty;
        strPath = Convert.ToString(ConfigurationSettings.AppSettings["BriefDoc"]) + Convert.ToString(objDocumentFile);
        strPath = "javascript:onClickLink('" + strPath.Replace("~", "..") + "')";
        return strPath;
    }
    public string GetProposalBriefDocumentDownload(object objProposalDocumentFile)
    {
        string strPathProDoc = string.Empty;
        strPathProDoc = Convert.ToString(ConfigurationSettings.AppSettings["ProposalPath"]) + Convert.ToString(objProposalDocumentFile);
        strPathProDoc = "javascript:onClickLinkProposal('" + strPathProDoc.Replace("~", "..") + "')";
        return strPathProDoc;
    }

    //protected void lnkDownload_Click(object sender, EventArgs e)
    //{

    //    string strPath;
    //    string strAuthority = HttpContext.Current.Request.Url.Authority;

    //    string strBriefDocath = PathBriefDoc.Remove(0, 1);
    //    string strBriefName = txtHideanBTitle.Text.Trim();
    //    strPath = "http://" + strAuthority + strBriefDocath + strBriefName+".docx";


    //    //string filePath = (sender as LinkButton).CommandArgument;
    //    Response.ContentType = ContentType;
    //    Response.AppendHeader("Content-Disposition", "attachment; filename=" + strPath);
    //    Response.WriteFile(strPath);
    //    Response.End();
    //}

    //protected void lnkDownload_Click(object sender, EventArgs e)
    //{
    //    LinkButton lnkbtn = sender as LinkButton;
    //    GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
    //    string filePath = gvDetails.DataKeys[gvrow.RowIndex].Value.ToString();
    //    Response.ContentType = "image/jpg";
    //    Response.AddHeader("Content-Disposition", "attachment;filename=\"" + filePath + "\"");
    //    Response.TransmitFile(Server.MapPath(filePath));
    //    Response.End();
    //}
    protected void btnCancelProposal_Click(object sender, EventArgs e)
    {
        txtComments.Text = "";

    }
    protected void btnCancelContentAnalysis_Click(object sender, EventArgs e)
    {
        txtContentAnalysis.Text = "";

    }
    protected void btnCancelPastResearch_Click(object sender, EventArgs e)
    {
        txtPastResearch.Text = "";
    }
    protected void btnCancelMRResearch_Click(object sender, EventArgs e)
    {
        txtMRResearch.Text = "";
    }
    private void DeleteDocuments(long intDeleteDocument, int intDocumentTypeID)
    {

        CandidateBriefDetailBAL objCandidateBriefDetailBAL = new CandidateBriefDetailBAL();
        string strReturnValue;
        strReturnValue = (string)objCandidateBriefDetailBAL.SetDeleteCandidateBriefDocument(CommonUtility.GetLoggedOnUserId(), hdnCandidateBriefId.Value, hdnCandidateID.Value, hdnBriefID.Value, intDeleteDocument);

        if (strReturnValue == "SUCCESS")
        {
            gvProposalDocument.DataSource = objCandidateBriefDetailBAL.GetCandidateBriefDocumentByDocumentType(intDocumentTypeID, Convert.ToInt32(hdnCandidateID.Value), Convert.ToInt16(hdnBriefID.Value));
            gvProposalDocument.DataBind();
        }
    }


    protected void gvProposalDocument_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton lnkButton = (LinkButton)e.Row.FindControl("lnkDelete");

            lnkButton.Attributes.Add("onclick", "javascript:return " + "confirm('Are you sure you want to delete?')");

        }
    }
    protected void gvProposalDocument_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        long intGDID = (long)gvProposalDocument.DataKeys[e.RowIndex].Value;
        CandidateBriefDetailBAL objCandidateBriefDetailBAL = new CandidateBriefDetailBAL();
        DeleteDocuments(intGDID, 1);
        gvProposalDocument.DataSource = objCandidateBriefDetailBAL.GetCandidateBriefDocumentByDocumentType(1, Convert.ToInt32(hdnCandidateID.Value), Convert.ToInt16(hdnBriefID.Value));
        gvProposalDocument.DataBind();
    }
    private void DeleteContentAnalysisDocuments(long intDeleteDocument, int intDocumentTypeID)
    {

        CandidateBriefDetailBAL objCandidateBriefDetailBAL = new CandidateBriefDetailBAL();
        string strReturnValue;
        strReturnValue = (string)objCandidateBriefDetailBAL.SetDeleteCandidateBriefDocument(CommonUtility.GetLoggedOnUserId(), hdnCandidateBriefId.Value, hdnCandidateID.Value, hdnBriefID.Value, intDeleteDocument);

        if (strReturnValue == "SUCCESS")
        {
            gvContentAnalysis.DataSource = objCandidateBriefDetailBAL.GetCandidateBriefDocumentByDocumentType(intDocumentTypeID, Convert.ToInt32(hdnCandidateID.Value), Convert.ToInt16(hdnBriefID.Value));
            gvContentAnalysis.DataBind();
        }
    }
    protected void gvContentAnalysis_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton lnkButton = (LinkButton)e.Row.FindControl("lnkDelete");

            lnkButton.Attributes.Add("onclick", "javascript:return " + "confirm('Are you sure you want to delete?')");

        }
    }
    protected void gvContentAnalysis_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        long intGDID = (long)gvContentAnalysis.DataKeys[e.RowIndex].Value;
        CandidateBriefDetailBAL objCandidateBriefDetailBAL = new CandidateBriefDetailBAL();
        DeleteContentAnalysisDocuments(intGDID, 3);
        gvContentAnalysis.DataSource = objCandidateBriefDetailBAL.GetCandidateBriefDocumentByDocumentType(3, Convert.ToInt32(hdnCandidateID.Value), Convert.ToInt16(hdnBriefID.Value));
        gvContentAnalysis.DataBind();
    }
    private void DeletePastResearchDocuments(long intDeleteDocument, int intDocumentTypeID)
    {

        CandidateBriefDetailBAL objCandidateBriefDetailBAL = new CandidateBriefDetailBAL();
        string strReturnValue;
        strReturnValue = (string)objCandidateBriefDetailBAL.SetDeleteCandidateBriefDocument(CommonUtility.GetLoggedOnUserId(), hdnCandidateBriefId.Value, hdnCandidateID.Value, hdnBriefID.Value, intDeleteDocument);

        if (strReturnValue == "SUCCESS")
        {
            gvPastResearch.DataSource = objCandidateBriefDetailBAL.GetCandidateBriefDocumentByDocumentType(intDocumentTypeID, Convert.ToInt32(hdnCandidateID.Value), Convert.ToInt16(hdnBriefID.Value));
            gvPastResearch.DataBind();
        }
    }

    protected void gvPastResearch_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton lnkButton = (LinkButton)e.Row.FindControl("lnkDelete");

            lnkButton.Attributes.Add("onclick", "javascript:return " + "confirm('Are you sure you want to delete?')");

        }
    }
    protected void gvPastResearch_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        long intGDID = (long)gvPastResearch.DataKeys[e.RowIndex].Value;
        CandidateBriefDetailBAL objCandidateBriefDetailBAL = new CandidateBriefDetailBAL();
        DeletePastResearchDocuments(intGDID, 4);
        gvPastResearch.DataSource = objCandidateBriefDetailBAL.GetCandidateBriefDocumentByDocumentType(4, Convert.ToInt32(hdnCandidateID.Value), Convert.ToInt16(hdnBriefID.Value));
        gvPastResearch.DataBind();
    }

    private void DeleteMRResearchDocuments(long intDeleteDocument, int intDocumentTypeID)
    {

        CandidateBriefDetailBAL objCandidateBriefDetailBAL = new CandidateBriefDetailBAL();
        string strReturnValue;
        strReturnValue = (string)objCandidateBriefDetailBAL.SetDeleteCandidateBriefDocument(CommonUtility.GetLoggedOnUserId(), hdnCandidateBriefId.Value, hdnCandidateID.Value, hdnBriefID.Value, intDeleteDocument);

        if (strReturnValue == "SUCCESS")
        {
            gvMRResearch.DataSource = objCandidateBriefDetailBAL.GetCandidateBriefDocumentByDocumentType(intDocumentTypeID, Convert.ToInt32(hdnCandidateID.Value), Convert.ToInt16(hdnBriefID.Value));
            gvMRResearch.DataBind();
        }
    }
    protected void gvMRResearch_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {

        long intGDID = (long)gvMRResearch.DataKeys[e.RowIndex].Value;
        CandidateBriefDetailBAL objCandidateBriefDetailBAL = new CandidateBriefDetailBAL();
        DeletePastResearchDocuments(intGDID, 5);
        gvMRResearch.DataSource = objCandidateBriefDetailBAL.GetCandidateBriefDocumentByDocumentType(5, Convert.ToInt32(hdnCandidateID.Value), Convert.ToInt16(hdnBriefID.Value));
        gvMRResearch.DataBind();
    }
    protected void gvMRResearch_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton lnkButton = (LinkButton)e.Row.FindControl("lnkDelete");

            lnkButton.Attributes.Add("onclick", "javascript:return " + "confirm('Are you sure you want to delete?')");

        }
       
    }
}